package cmm;

/**
 * 符号表
 */
public class VarSymbol {
    private String name;          //变量的名称，包括临时变量
    private VarType type;         //变量的类型
    private String value;         //变量的值
    private int size;             //数组变量的大小
    private int level=-1;         //变量所在的作用域

    public VarSymbol(String name,VarType type,int size,int level){
        this.name=name;
        this.type=type;
        this.size=size;
        this.level=level;
    }

    public VarSymbol(String name,VarType type,int level){
        this.name=name;
        this.type=type;
        this.level=level;
        if(level!=0){
            this.value="0";
        }
    }

    public VarSymbol(String name,VarType type,String value,int level){
        this.name=name;
        this.type=type;
        this.value=value;
        this.level=level;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public VarType getType() {
        return type;
    }

    public void setType(VarType type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }
}
